﻿using System;
using SpreadsheetGear;
using SpreadsheetGear.Windows.Forms;
using System.Windows;

namespace DesignerHelper.EventHandlers
{
    public delegate void BookSetEventHandler(object sender, BookSetEventArgs e);
    public class BookSetEventArgs : EventArgs
    {
        /// <summary>
        /// 增加或删除的工作簿
        /// </summary>
        public IWorkbook ActiveWorkbookInternal { get; private set; }
        /// <summary>
        /// 增加或删除的工作表(操作对象为工作簿时该值为null)
        /// </summary>
        public IWorksheet ActiveWorksheetInternal { get; }
        /// <summary>
        /// 操作类型，添加、删除、刷新工作簿/工作表
        /// </summary>
        public Type Status { get; private set; }


        public enum Type
        {
            /// <summary>
            /// 表示该操作增加一个工作簿或工作表
            /// </summary>
            Add = 0,
            /// <summary>
            /// 表示该操作移除一个工作簿或工作表
            /// </summary>
            Remove = 1,
            /// <summary>
            /// 表示该工作簿或工作表需要刷新
            /// </summary>
            Refresh = 2,
        }


        public BookSetEventArgs(IWorkbook activeWorkbook, Type operationType)
        {
            ActiveWorkbookInternal = activeWorkbook;
            ActiveWorksheetInternal = null;//重要
            Status = operationType;
        }

        public BookSetEventArgs(IWorksheet activeWorksheet, Type operationType)
        {
            ActiveWorksheetInternal = activeWorksheet;
            ActiveWorkbookInternal = ActiveWorksheetInternal.Workbook;
            Status = operationType;
        }

    }


}